class ApplicationController < ActionController::Base
  helper :all 
  
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
  helper_method :title, :title=
  
  @@DEFAULT_TITLE = "淘宝网女装_淘宝女装网"
  #@@GB_STR_REG = /0-9A-Za-z&-;~!^◆●★╭＊╯■/
  
  def item_id_by_params(params_id)
  	params_id.match(/\d+_(\d+)/)
  	$1
  end
  
  def category_id_by_params(params_id)
  	params_id.match(/(\d+)_\d+/)
  	$1
  end
	
	def title=(title)
    @title = title
  end

  def title
    title_string = @title.blank? ? accurate_title : @title
    if title_string.blank?
      @@DEFAULT_TITLE
    else
      [title_string, @@DEFAULT_TITLE ].join('_')
    end
  end
  
  def render_404(exception)
    respond_to do |type|
      type.html { render :file    => "#{RAILS_ROOT}/public/404.html", :status => "404 Not Found" }
      type.all  { render :nothing => true,                            :status => "404 Not Found" }
    end
  end
  
  protected
  
  def accurate_title
    return nil
  end
  
end
